import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import NotFound from '../pages/home/notFound/index';
import Redirect from '../pages/home/redirect';
import Empty from '../pages/home/notFound/empty';
export type RouterType = RouteRecordRaw & { chname?: string; icon?: string; children?: any };
const homeRouter = [
  {
    name: 'home',
    path: '/',
    component: () => import('../pages/menu/menu'),
    children: [
      {
        chname: '我的班级',
        name: 'class',
        path: `/class`,
        component: Empty
      },
      {
        chname: '我的学员',
        name: 'student',
        path: `/student`,
        component: Empty
      },
      {
        chname: '我的私海',
        name: 'privateSea',
        path: `/privateSea`,
        component: Empty
      },
      {
        chname: '常用工具',
        name: 'commonTool',
        path: `/commonTool`,
        component: Empty
      }
    ]
  }
];

export const routes: RouteRecordRaw[] = (homeRouter as RouteRecordRaw[]).concat([
  {
    name: 'redirect', // 首页
    path: '/redirect',
    component: Redirect
  },
  {
    name: 'notFound',
    path: '/:pathMatch(.*)*',
    component: NotFound
  }
]);

export const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHashHistory(import.meta.env.BASE_URL), // es2019编译目标下import.env不支持
  routes
});

export default router;
